/* --------------------------------------------------------------------------
 * This code is written by Przemek Jaworski, Flora Salim, Rafael Urquiza, 
 * Rafael Roa, and Jose Luis in SmartGeometry 2011: Interacting with the City
 * based on the sample code from SimpleOpenNI: DepthMap3d Test
 * This class is used to sample points from Kinect point cloud to be sent to UbiMash then GC
 * ----------------------------------------------------------------------------
 */
class controlPoint
{
  float x,y,z;
  
  void display()
 {
   pushMatrix();
     stroke(255);
     translate(x,y,z);
       ellipse(0,0,4,4);
     line(-5,-5,5,5);
     line(-5,5,5,-5);
   popMatrix();
  }
}

//prepare data for control points
controlPoint [] cPoints = new controlPoint[200];
int numCPoints;

//prepare buffer of points
PVector [] pointBuffer = new PVector[20];
int numPointsBuffered = 0;



void drawControlPoints()
{
  fill(255);  
  int scaleZ = 800;
  String ptlist = "{";
  String[] ptStr = new String[numCPoints]; 
  
  for (int i=0;i<numCPoints;i++)
  {
    //flip coordinates from Processing to GC
    String joinedNumbers = floor(cPoints[i].x) + ":" + floor(cPoints[i].y) + ":" + floor(-cPoints[i].z + scaleZ);
    ptStr[i] = joinedNumbers;
    cPoints[i].display();
  }
  
   String joinedPtStr = join(ptStr, ";");
   ptlist += joinedPtStr + "}";
   println(ptlist);
   publishVar("ptList",ptlist);  
}

